const express = require('express');

let app = express();

// 定义路由中间件
let checkCodeMiddleware = (req, res, next) => {
    if (req.query.code == 123) {
        next()
    } else {
        res.send('暗号错误')
    }
}
// 路由
app.get('/login', checkCodeMiddleware, (req, res) => {
    res.send('登录页')
})
app.get('/reg', checkCodeMiddleware, (req, res) => {
    res.send('注册页')
})

app.all('*', (req, res) => {
    res.send('404 NOT FOUND')
})

app.listen(9527, () => {
    console.log('启动成功....');
})